Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

m3u8-parser

Package Overview
Dependencies
Maintainers
22
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

m3u8-parser

m3u8 parser

  • 6.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
22
Created

What is m3u8-parser?

The m3u8-parser npm package is a library for parsing M3U8 files, which are used for HTTP Live Streaming (HLS). It allows you to parse M3U8 playlists and extract information such as segments, media sequences, and more.

What are m3u8-parser's main functionalities?

Parsing M3U8 Playlists

This feature allows you to parse an M3U8 playlist string and convert it into a JavaScript object. The code sample demonstrates how to use the Parser class to parse a simple M3U8 string and log the resulting manifest object.

const { Parser } = require('m3u8-parser');
const parser = new Parser();
const m3u8String = '#EXTM3U\n#EXTINF:10,\nhttp://media.example.com/first.ts\n#EXTINF:10,\nhttp://media.example.com/second.ts\n#EXT-X-ENDLIST';
parser.push(m3u8String);
parser.end();
console.log(parser.manifest);

Extracting Segment Information

This feature allows you to extract information about individual segments from an M3U8 playlist. The code sample demonstrates how to parse an M3U8 string and then iterate over the segments to log their URI and duration.

const { Parser } = require('m3u8-parser');
const parser = new Parser();
const m3u8String = '#EXTM3U\n#EXTINF:10,\nhttp://media.example.com/first.ts\n#EXTINF:10,\nhttp://media.example.com/second.ts\n#EXT-X-ENDLIST';
parser.push(m3u8String);
parser.end();
const segments = parser.manifest.segments;
segments.forEach(segment => {
  console.log(`URI: ${segment.uri}, Duration: ${segment.duration}`);
});

Handling Media Sequences

This feature allows you to handle media sequences in an M3U8 playlist. The code sample demonstrates how to parse an M3U8 string and log the media sequence number from the resulting manifest object.

const { Parser } = require('m3u8-parser');
const parser = new Parser();
const m3u8String = '#EXTM3U\n#EXT-X-MEDIA-SEQUENCE:1\n#EXTINF:10,\nhttp://media.example.com/first.ts\n#EXTINF:10,\nhttp://media.example.com/second.ts\n#EXT-X-ENDLIST';
parser.push(m3u8String);
parser.end();
console.log(`Media Sequence: ${parser.manifest.mediaSequence}`);

Other packages similar to m3u8-parser

Keywords

FAQs

Package last updated on 25 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc